#ifndef _GLOBAL_H_
#define _GLOBAL_H_

#define MAX_NAME_LENGTH 20
#define MAX_PASS_LENGTH 20
#define MAX_EMAIL_LENGTH 100

typedef enum {
	LOG_QUIET,
	LOG_ERROR,
	LOG_WARNING,
	LOG_GENERAL,
	LOG_VERBOSE,
	LOG_DEBUG
} verbosity;

typedef enum {
	CL_AUTHENTICATE,
	CL_CREATE_ACCOUNT,
	CL_MODIFY_ACCOUNT,
	CL_GETSERVERINFO,
	CL_SAY,
	CL_DISCONNECT
} client_actions;

typedef enum {
	SV_SUCCESS,
	SV_DISCONNECT,
	SV_ERROR,
	SV_MSG
} response_types;

typedef enum {
	ERR_NONE,
	ERR_INTERNAL,
	ERR_CORRUPT_CLIENT_MESSAGE,
	ERR_USER_EXISTS,
	ERR_NONEXISTANT_USER,
	ERR_EMAIL_IN_USE,
	ERR_INCORRECT_PASSWORD
} server_error;

typedef struct {
	client_actions action;
	union { int size; int length; int wait; };
	union {
		char msg[1024 - sizeof(client_actions) - sizeof(int)];
		struct {
			char username[MAX_NAME_LENGTH];
			char password[MAX_PASS_LENGTH];
			char email[MAX_EMAIL_LENGTH];
		};
	};
} action_data;

typedef struct {
	response_types type;
	union { int size; int length; int wait; };
	union {
		char msg[1024 - sizeof(response_types) - sizeof(int)];
		struct {
			client_actions previous_action;
			server_error error;
		};
	};
} server_response;

#define ACTION_MSG_LENGTH (1024 - sizeof(client_actions) - sizeof(int))
#define RESPONSE_MSG_LENGTH (1024 - sizeof(response_types) - sizeof(int))

#endif // _GLOBAL_H_

